﻿using System;
using MagistrAPI.Enums;
using MagistrAPI.MathModel;
using NUnit.Framework;

namespace TestMagistrAPI
{
    [TestFixture]
    class SystemOfEquationsTextFixture
    {
        private double[] _args;

        [SetUp]
        public void Init()
        {
            _args = new[]
                        {
                            -3608998.7560643037,
                            2027424.9206698083,
                            4916970.4170327466,
                            -959.5669302239,
                            -400.9768981914,
                            1440.0052077401,
                            0.9,
                            0.5,
                            0.1,
                            -0.5312373217,
                            0.1932648074,
                            -0.8248852176,
                            0.6793037655,
                            0.6790008846,
                            -0.2783957488,
                            0.5062936916,
                            -0.7082418464,
                            -0.4919961228
                        };
        }

        //[Test]
        //public void TestX()
        //{
        //    var x = (Func<double, double>)SystemOfEquations.Equations[Equations.X];
        //    Assert.AreEqual(3.0, x(3.0));
        //}

        //[Test]
        //public void TestY()
        //{
        //    var y = (Func<double, double>)SystemOfEquations.Equations[Equations.Y];
        //    Assert.AreEqual(3.0, y(3.0));
        //}

        //[Test]
        //public void TestZ()
        //{
        //    var z = (Func<double, double>)SystemOfEquations.Equations[Equations.Z];
        //    Assert.AreEqual(3.0, z(3.0));
        //}

        [Test]
        public void TestVx()
        {
            var vX = (Func<double[], double>) SystemOfEquations.Equations[Equations.Vx];
            Assert.AreEqual(Math.Round(5.4297005723, 2), Math.Round(vX(_args), 2));
        }

        [Test]
        public void TestVy()
        {
            var vY = (Func<double[], double>)SystemOfEquations.Equations[Equations.Vy];
            Assert.AreEqual(Math.Round(-3.0245394642, 2), Math.Round(vY(_args), 2));
        }

        [Test]
        public void TestVz()
        {
            var vZ = (Func<double[], double>)SystemOfEquations.Equations[Equations.Vz];
            Assert.AreEqual(Math.Round(-7.3920517675, 2), Math.Round(vZ(_args), 2));
        }

        [Test]
        public void TestWx()
        {
            var wX = (Func<double[], double>)SystemOfEquations.Equations[Equations.Wx];
            Assert.AreEqual(0, wX(_args));

        }

        [Test]
        public void TestWy()
        {
            var wY = (Func<double[], double>)SystemOfEquations.Equations[Equations.Wy];
            Assert.AreEqual(Math.Round(0.0849056604, 5), Math.Round(wY(_args), 5));

        }

        [Test]
        public void TestWz()
        {
            var wZ = (Func<double[], double>) SystemOfEquations.Equations[Equations.Wz];
            Assert.AreEqual(Math.Round(-0.4265339163, 5), Math.Round(wZ(_args), 5));
        }

        [Test]
        public void TestLx()
        {
            var lX = (Func<double[], double>)SystemOfEquations.Equations[Equations.Lx];
            Assert.AreEqual(Math.Round(0.4317690895, 5), Math.Round(lX(_args), 5));

        }

        [Test]
        public void TestLy()
        {
            var lY = (Func<double[], double>)SystemOfEquations.Equations[Equations.Ly];
            Assert.AreEqual(Math.Round(-0.6892729637, 5), Math.Round(lY(_args), 5));

        }

        [Test]
        public void TestLz()
        {
            var lZ = (Func<double[], double>)SystemOfEquations.Equations[Equations.Lz];
            Assert.AreEqual(Math.Round(-0.4395569875, 5), Math.Round(lZ(_args), 5));
        }

        [Test]
        public void TestMx()
        {
            var mX = (Func<double[], double>)SystemOfEquations.Equations[Equations.Mx];
            Assert.AreEqual(Math.Round(0.2070979629, 5), Math.Round(mX(_args), 5));
        }

        [Test]
        public void TestMy()
        {
            var mY = (Func<double[], double>)SystemOfEquations.Equations[Equations.My];
            Assert.AreEqual(Math.Round(-0.3184865505, 5), Math.Round(mY(_args), 5));
        }

        [Test]
        public void TestMz()
        {
            var mZ = (Func<double[], double>)SystemOfEquations.Equations[Equations.Mz];
            Assert.AreEqual(Math.Round(-0.2714489134, 5), Math.Round(mZ(_args), 5));
        }

        [Test]
        public void TestNx()
        {
            var nX = (Func<double[], double>)SystemOfEquations.Equations[Equations.Nx];
            Assert.AreEqual(Math.Round(0.1751738768, 5), Math.Round(nX(_args), 5));
        }

        [Test]
        public void TestNy()
        {
            var nY = (Func<double[], double>)SystemOfEquations.Equations[Equations.Ny];
            Assert.AreEqual(Math.Round(-0.4934258797, 5), Math.Round(nY(_args), 5));
        }

        [Test]
        public void TestNz()
        {
            var nZ = (Func<double[], double>)SystemOfEquations.Equations[Equations.Nz];
            Assert.AreEqual(Math.Round(0.8905645076, 5), Math.Round(nZ(_args), 5));
        }

    }
}
